package plugins;

import java.awt.Color;

import javax.swing.ImageIcon;

import framework.Framework;
import framework.VisualizerImpl; 

/** 
 * A simple plugin to demonstrate how developer could use the framework
 */
public class Plugin {

	private final ImageIcon rabbitImage = 
			new ImageIcon(getClass().getResource("../icons/rabbit.gif"));

	private ImageIcon getRabbit(){
		return rabbitImage;
	}
	/** 
	 * Sets up framework, sets up cells, sets up visualizer.
	 * A simple setup that shows the functionality of the framework
	 * and how a plugin developer could implement it
	 */
	public static void main(String[] args){
		Plugin plugin = new Plugin();
		Framework fw = new Framework();
		ConwayCell[][] cells = new ConwayCell[8][8];
		for (int i = 0; i < cells.length; i++){
			for (int j = 0; j < cells[0].length; j++){
				cells[i][j] = new ConwayCell();
				if(i % 2 == 1)
				cells[i][j].setState(new DeadState());
				else
				cells[i][j].setState(new AliveState());
			}
		}
		fw.initialstate(cells, cells.length, cells[0].length);
		VisualizerImpl viz = new VisualizerImpl(fw.getBoard(),fw);
		viz.setStateIcon(new AliveState(), plugin.getRabbit());
		//viz.setStateColor(new AliveState(), Color.black);
		viz.setStateColor(new DeadState(), Color.white);
		fw.setVisualizer(viz);
		try {
			fw.run();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}